算法封装层开发流程
修订日期 | 修订版本 | 修订内容 | 修订人 |
---|---|---|---|
2023.12.04 | v0.1 | 初始化文档 | 张弛 |
一、开发过程涉及模块层级分析
二、Aral_wrapper中的代码开发
aral_wrapper中的实现控制功能的文件为dynamic.hpp,算法各部分均有对应的文件。
以目前关节空间导纳流程为例,Aral_wrapper中实现一个功能需要三步,使能—实现—失能。
使能
使能函数:
int BatteryAssemblyEnable(RobotModelPtr robot_model, const Input &input) override
功能:初始化算法库控制模式(SetControlType)、状态参数(InitiateRobotState)、控制器mdk参数等。
实现 实现函数:
int BatteryAssemblyCmdOut(RobotModelPtr robot_model, const Input &input, Output &output) override
功能:计算控制输出
失能函数 形式暂未确定。(提issue)
三、common_interface中的代码调用
虚函数声明 对于在Aral_wrapper中重写的功能包接口函数,需要在common_interface的基类中声明其虚函数。 如:
virtual int BatteryAssemblyCmdOut(RobotModelPtr robot_model, const Input &input, Output &output) = 0; virtual int BatteryAssemblyEnable(RobotModelPtr robot_model, const Input &input) = 0;
输出参数、输出参数的定义 在common_interface中定义了用户输出参数Input结构体,以及控制输出参数Output结构体,任何输入及输出参数均在这俩结构体中定义。
四、minico中调用功能包接口
对CPM文件夹(缓存区?)中的aral_wrapper与common_interface中更新 操作方式:改变模块所属分支或commit
引入aral_wrapper的头文件
#include "../peripheral/aral/aral_wrapper_standalone/src/dynamics.hpp" #include "../peripheral/aral/aral_wrapper_standalone/src/robot_model.hpp"
实例化aral_wrapper动力学计算及模型计算的对象,获得算法库实例指针
LogHandler log_handler_; DynamicsSolver::Input state_input; DynamicsSolver::Output cmd_out; auto dynamics_solver_ =std::make_shared<arcs::aubo_control::DynamicsSolver1>(log_handler_); auto robot_model_=std::make_shared<arcs::aubo_control::RobotModel1>(robot_name, log_handler_); auto aral = robot_model_->getAralInterface();
后续操作同以前,可参考例程](http://git.aubo-robotics.cn:8001/arcs/minico/-/blob/lw-wrapper_test/app/wrapper_assembly_demo.cpp))